home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Presentations / Presentations ’96 / Sessions ’96 / Netscape Plugins in PowerPlant / Test.hex < prev   
Encoding:
Text File  |  1996-06-16  |  467 b   |  29 lines  |  [TEXT/CWIE]

  1. //
  2. // Case-independent string comparison.
  3. //
  4.  
  5. #include "UCIString.h"
  6. #include <ctype.h>
  7.  
  8. int cistrcmp(const char *s, const char *t) {
  9.     int sc, tc;
  10.     for (;;) {
  11.         sc = tolower(*s++);
  12.         tc = tolower(*t++);
  13.         if (sc != tc || sc == 0) 
  14.             break;
  15.     }
  16.     return sc - tc;
  17. }
  18.  
  19. int cistrncmp(const char *s, const char *t, size_t n) {
  20.     while (n-- > 0) {
  21.         int sc = tolower(*s++);
  22.         int tc = tolower(*t++);
  23.         int d = sc - tc; 
  24.         if (d) return d;
  25.         if (!sc) return 0;
  26.     }
  27.     return 0;
  28. }
  29.